package face.com.androidfacesdk;

import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import java.io.File;

public class MainActivity extends AppCompatActivity {

    static {
        System.loadLibrary("caffe");
        System.loadLibrary("caffe_jni");
        File destDir = new File("/sdcard/wis");
        if (!destDir.exists()) {
            destDir.mkdirs();
        }
    }
    public static  String modelDir = "/sdcard/wis";
    public static  FaceMobile wisMobile;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    // Example of a call to a native method
    TextView tv = (TextView) findViewById(R.id.sample_text);
    tv.setText(stringFromJNI());
    }

    /**
     * A native method that is implemented by the 'native-lib' native library,
     * which is packaged with this application.
     */
    public native String stringFromJNI();

    // Used to load the 'native-lib' library on application startup.
    static {
        modelDir = Environment.getExternalStorageDirectory().getPath()+"/wis";
        System.loadLibrary("caffe");
        System.loadLibrary("caffe_jni");
        wisMobile = new FaceMobile();
        wisMobile.setNumThreads(1);

        //modelDir = Environment.getExternalStorageDirectory().getPath();
        wisMobile.loadModel(modelDir);//modelDir为wis所在的目录
    }
}
